package com.m3839.sdk.pay.platform.wechat;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;

import com.m3839.sdk.common.core.SdkConfiguration;
import com.m3839.sdk.pay.bean.OrderInfo;
import com.m3839.sdk.pay.platform.PayResultCallBack;
import com.m3839.sdk.pay.platform.PayWrapper;

/**
 * 描述信息:微信支付包装类
 *
 * @author chenbaoyang
 * @create 2021/11/3
 */
public class WechatPayWrapper implements PayWrapper {

  /** 订单已提交 */
  public static final String HYKB_WECHATH5_CODE_SUBMIT = "9001";

  public static final String HYKB_WECHATH5_MSG_SUBMIT = "订单已提交，等待处理中";

  @Override
  public void doPay(Activity activity, OrderInfo orderInfo, PayResultCallBack callBack) {
    //Uri uri = Uri.parse("weixin://wap/pay?prepayid%3Dwx021710254123411d05c0ae7f1701735900&package=2134161975&noncestr=1577956225&sign=55839cd3b859f37f9b84a0c857dbe57a");
    Uri uri = Uri.parse(orderInfo.payParams.url);
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    SdkConfiguration.getAppContext().startActivity(intent);

    callBack.onResult(false, HYKB_WECHATH5_CODE_SUBMIT,  HYKB_WECHATH5_MSG_SUBMIT);
  }
}
